package com.mzj.saas.mservice.property.controller;

import com.mzj.saas.annotation.RepeatSubmit;
import com.mzj.saas.commons.ApiData;
import com.mzj.saas.commons.ResultBean;
import com.mzj.saas.mservice.bill.vo.*;
import com.mzj.saas.mservice.property.service.EstateBillService;
import com.mzj.saas.mservice.property.vo.*;
import com.mzj.saas.mservice.propertybill.vo.PenalSumVO;
import com.mzj.saas.redis.RedisService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 物业-费用app接口
 */
@Controller
@RequestMapping("/estateBill")
@Api(tags = "费用接口")
public class EstateBillController {
    @Autowired
    private EstateBillService estateBillService;
    @Autowired
    private RedisService redisService;

    /**
     * 租金账单列表
     *
     * @param accessToken
     * @param residenceCommunityId
     * @param buildingNum
     * @param unit
     * @param roomNumber
     * @param pageNumber
     * @param pageSize
     * @return
     */
    @GetMapping("/rentBillList")
    @ResponseBody
    public ResultBean<BillApiData<RentBillListVO>> rentBillList(@RequestHeader String accessToken,
                                                                @RequestParam(required = false) String residenceCommunityId,
                                                                @RequestParam(required = false) Long buildingNum,
                                                                @RequestParam(required = false) Long unit,
                                                                @RequestParam(required = false) String roomNumber,
                                                                @RequestParam(defaultValue = "0") Integer pageNumber,
                                                                @RequestParam(defaultValue = "5") Integer pageSize,
                                                                @RequestParam(required = false) Long id) {
        return estateBillService.rentBillList(accessToken, residenceCommunityId, buildingNum, unit, roomNumber, pageNumber, pageSize, id);
    }

    /**
     * 租金账单详情
     *
     * @param id
     * @return
     */
    @GetMapping("/rentBillDetail")
    @ResponseBody
    public ResultBean<RentBillDetailVO> rentBillDetail(@RequestParam(value = "id") Long id) {
        return estateBillService.rentBillDetail(id);
    }

    /**
     * 其他费用列表
     *
     * @param accessToken
     * @param residenceCommunityId
     * @param buildingNum
     * @param unit
     * @param roomNumber
     * @param chargeType
     * @param pageNumber
     * @param pageSize
     * @return
     */
    @GetMapping("/expenseBillList")
    @ResponseBody
    public ResultBean<BillApiData<ExpenseBillListVO>> expenseBillList(@RequestHeader String accessToken,
                                                                      @RequestParam(required = false) String residenceCommunityId,
                                                                      @RequestParam(required = false) Long buildingNum,
                                                                      @RequestParam(required = false) Long unit,
                                                                      @RequestParam(required = false) String roomNumber,
                                                                      @RequestParam(value = "chargeType", required = false) Integer chargeType,
                                                                      @RequestParam(defaultValue = "0") Integer pageNumber,
                                                                      @RequestParam(defaultValue = "5") Integer pageSize,
                                                                      @RequestParam(required = false) Long id) {
        return estateBillService.expenseBillList(accessToken, residenceCommunityId, buildingNum, unit, roomNumber, chargeType, pageNumber, pageSize, id);
    }

    /**
     * 支付记录
     *
     * @param accessToken
     * @param businessType 账单类型
     * @param pageNumber
     * @param pageSize
     * @return
     */
    @GetMapping("/paymentOrderList")
    @ResponseBody
    public ResultBean<PaymentOrderApiData<PaymentOrderListVO>> paymentOrderList(@RequestHeader String accessToken,
                                                                                @RequestParam(value = "businessType", required = false) Integer businessType,
                                                                                @RequestParam(defaultValue = "0") Integer pageNumber,
                                                                                @RequestParam(defaultValue = "5") Integer pageSize) {
        return estateBillService.paymentOrderList(accessToken, businessType, pageNumber, pageSize);
    }

    /**
     * 物业房产-租金/押金app支付
     *
     * @param accessToken
     * @return
     */
    @PostMapping("/payment")
    @ResponseBody
    public ResultBean<Map<String, Object>> payment(@RequestHeader String accessToken, @RequestBody RentBillPaymentVo vo) {
        return estateBillService.payment(accessToken, vo);
    }

    /**
     * 物业房产-其它费用账单APP支付
     *
     * @param accessToken
     * @param vo
     * @return
     * @author shun
     * @date 2021年7月12日
     */
    @PostMapping("/other/payment")
    @ResponseBody
    public ResultBean<Map<String, Object>> OtherPayment(@RequestHeader String accessToken, @RequestBody RentBillPaymentVo vo) {
        return estateBillService.otherPayment(accessToken, vo);
    }

    /**
     * 小程序-余额充值支付
     *
     * @param accessToken
     * @param vo
     * @return
     * @author qixi
     * @date 2022年12月9日
     */
    @PostMapping("/payRemaining")
    @ResponseBody
    @RepeatSubmit
    @ApiOperation(notes = "余额充值支付", value = "余额充值")
    public ResultBean<Map<String, Object>> payRemaining(@RequestHeader String accessToken, @RequestBody RentBillPaymentRemainingVo vo) {
        return estateBillService.payRemaining(accessToken, vo);
    }

    /**
     * 小程序-余额查询
     *
     * @param accessToken
     * @param vo
     * @return
     * @author qixi
     * @date 2022年12月9日
     */
    @PostMapping("/findRemaining")
    @ResponseBody
    @ApiOperation(notes = "余额查询", value = "余额查询")
    public ResultBean<PaymentRemainingApiData<RemainingVo,HouseRemainingRecordVo>> findRemaining(@RequestHeader String accessToken, @RequestBody BalanceVo vo) {
        return estateBillService.findRemaining(accessToken, vo);
    }


    /**
     * 小程序-未缴费明细
     *
     * @param accessToken
     * @param vo
     * @return
     * @author qixi
     * @date 2022年12月13日
     */
    @PostMapping("/notPayment")
    @ResponseBody
    @ApiOperation(notes = "未缴费明细", value = "未缴费明细")
    public ResultBean<NotPaymentApiData<NotPaymentListVo>> notPayment(@RequestHeader String accessToken, @RequestBody NotPaymentVo vo) {
        return estateBillService.notPayment(accessToken, vo);
    }

    /**
     * 小程序-违约金账单支付
     *
     * @param accessToken
     * @param vo
     * @return
     * @author qixi
     * @date 2022年12月19日
     */
    @PostMapping("/other/appletPayment")
    @ResponseBody
    @ApiOperation("违约金账单支付")
    public ResultBean<Map<String, Object>> appletOtherPayment(@RequestHeader String accessToken, @RequestBody RentBillPaymentVo vo) {
        return estateBillService.appletOtherPayment(accessToken, vo);
    }

    /**
     * 小程序-租金|押金账单支付
     *
     * @param accessToken
     * @param vo
     * @return
     * @author qixi
     * @date 2022年12月21日
     */
    @PostMapping("/appletPayment")
    @ResponseBody
    @ApiOperation("租金/押金账单支付")
    public ResultBean<Map<String, Object>> appletPayment(@RequestHeader String accessToken, @RequestBody RentBillPaymentVo vo ) {
        return estateBillService.appletPayment(accessToken, vo);
    }

    /**
     * 小程序-账单合计列表
     *
     * @param accessToken
     * @author qixi
     * @date 2022年12月21日
     */
    @PostMapping("/billList")
    @ResponseBody
    @ApiOperation("账单合计列表")
    public ResultBean<BillApiData<BillListVo>> billList(@RequestHeader String accessToken,@RequestBody BillAllVo vo) {
        return estateBillService.billList(accessToken,vo);
    }


    /**
     * 小程序-未缴费余额扣减
     *
     * @param accessToken
     * @author qixi
     * @date 2023年1月10日
     */
    @PostMapping("/remPayment")
    @ResponseBody
    public ResultBean<Map<String, Object>> remPayment(@RequestHeader String accessToken,@RequestBody RentBillPaymentVo vo) {
        return estateBillService.billRemainingPayment(accessToken,vo);
    }


    /**
     * 小程序-违约金列表
     *
     * @param accessToken
     * @author qixi
     * @date 2023年2月20日
     */
    @PostMapping("/violateList")
    @ResponseBody
    @ApiOperation("违约金列表")
    public ResultBean<ApiData<PenalSumVO>> violateList(@RequestHeader String accessToken, @RequestBody BillAllVo vo) {
        return estateBillService.violateList(accessToken,vo);
    }


}
